﻿using System;
using System.Reflection;
using Castle.ActiveRecord;
using Castle.ActiveRecord.Framework.Config;
using Hadlow.Jobvertizer.Models;
using Castle.ActiveRecord.Framework;

namespace Hadlow.Jobvertizer.Tests.Repositories
{
    public abstract class RepositoryTestBase
    {
        public RepositoryTestBase()
        {
            try
            {
                // we only want to initialise active record once
                XmlConfigurationSource config = new XmlConfigurationSource("ActiveRecord.config");
                ActiveRecordStarter.Initialize(Assembly.GetAssembly(typeof(Job)), config);
                    //typeof(Job),
                    //typeof(Location),
                    //typeof(Poster),
                    //typeof(PosterUser),
                    //typeof(User),
                    //typeof(Role),
                    //typeof(Salary),
                    //typeof(Location),
                    //typeof(CreditCard),
                    //typeof(CardType));

            }
            catch (ActiveRecordInitializationException)
            {
                // I can't work out a way to test if ActiveRecordStarter.Initialize has already been called,
                // so I'm just burying the error :(
            }
        }
    }
}
